<?php
declare (strict_types = 1);

namespace app\validate;

use think\Validate;

class User extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */
	protected $rule = [
			'name' => 'require',
			'phone'=>'mobile',
			'email'=>'email',
			'password'=>'require|between:6,32',
			'switch' => 'number|in:0,1',
	];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */
    protected $message = [
			 'name.require' => '必须填写昵称',
			 'phone.mobile' =>'必须是手机号码格式',
			 'email.email' => '请填写正确的邮箱格式',
			 'password.require' => '请填写密码',
			 'password.between' => '密码长度在6-32位之间',
			 'switch.number' => '0-1之间',
			 'switch.in' => '0-1之间',
		];

		protected $scene= [
				'login' => ['name','password'],
				'register'=>['name','phone','email','password'],
				'edit' => ['name','phone','email','password'],
		];
}
